<?php
/*
 * 下麦后的后续操作
 */

namespace App\Jobs\QiPao;

use App\Jobs\Job;
use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Log;

class DownWheatJob extends Job
{
    protected $room_id;   //房间id
    protected $pit_number;//麦位

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($room_id, $pit_number)
    {
        $this->room_id = $room_id;
        $this->pit_number = $pit_number;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        if(env('APP_ENV') != 'production'){
            Log::error('DownWheatJob:' . json_encode(['time' => getMillisecond(), 'data' => $this->room_id, 'pit_number' => $this->pit_number]));
        }
        try {
            app('model_room_pit')->getDownPitJob($this->room_id, $this->pit_number);
        } catch (BasicException $exception) {
            echo $exception->getMessage();
        } catch (\Exception $exception) {
            Log::error(__CLASS__.':'.$exception->getMessage());
            throw $exception;
        }
    }
}
